<!DOCTYPE html>
<title>Test WebAuthn navigator.credentials.create()</title>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="resources/utils.js"></script>

<body>

<script>
promise_test(async () => {
  const credentials_create_key = KEYS['credentials.create'];
  const credentials_create_ack_key = KEYS['credentials.create ACK'];

  attachFencedFrame('resources/create-credential-inner.https.html');
  // Get the result for the top-level fenced frame.
  const fenced_frame_result = await nextValueFromServer(credentials_create_key);
  assert_equals(
      fenced_frame_result, 'pass: fenced frame',
      'fenced frame has the right value' +
          ' for credentials.create');

  // Write an ACK, so that the fenced frame knows it can send message over the
  // `credentials_create_key` channel again.
  writeValueToServer(credentials_create_ack_key, 'ACK');

  // Get the result for the cross-origin fenced frame in the fenced frame.
  const cross_origin_fenced_frame_result =
      await nextValueFromServer(credentials_create_key);
  assert_equals(
    cross_origin_fenced_frame_result,
      'fail: fenced frame > cross-origin fenced frame',
      'The cross-origin fenced frame inside the top-level fenced frame has the' +
          'rejected value for `credentials.create`');
}, 'navigator.credentials.create');
</script>

</body>
